package ro.msg.quiz.dao;

import java.sql.SQLException;

//AUTHORS: Ervin

public class AnswersDB {

    public static void createAnswer(int idQuestion, String text, byte bit) throws ClassNotFoundException, SQLException {
	String sql = "INSERT into answers (idQuestion ,text,correct) values ('" + idQuestion + "','" + text + "',b'" + bit + "')";
	DatabaseCon.getInstance().executeUpdate(sql);
    }
    
    public static void deleteAnswer(int idQuestion) throws SQLException, ClassNotFoundException{
	String sql = "DELETE from answers where idQuestion =" + idQuestion;
	DatabaseCon.getInstance().executeUpdate(sql);
    }

    public static void updateAnswer(int idQuestion, String text) throws ClassNotFoundException, SQLException {
	String sql = "UPDATE answers set idQuestion = '" + idQuestion + "' where idQuestion =null and text = '" + text + "'";
	DatabaseCon.getInstance().executeUpdate(sql);
    }

}
